package com.stray.crawl.expr.psr;

import java.util.List;

import com.stray.crawl.expr.EventData;
import com.stray.crawl.expr.Express;

public class IndexParser extends Express {

	@Override
	protected Object doParse(EventData event) {
		Object obj = event.getObject();
		List<?> list = (List<?>) obj;
		int idx = event.toIntArgument();

		if (idx >= 0 && idx < list.size()) {
			obj = list.get(idx);
		}

		return obj;
	}

}
